package com.leo.leetcode.s100;

/**
 *
 * @author xuexiaolei
 * @version 2017年12月01日
 */
public class T83RemoveDuplicatesfromSortedList {
    public static ListNode deleteDuplicates(ListNode head) {
        ListNode cur = head;
        while (cur != null){
            if (cur.next !=null && cur.val == cur.next.val){
                cur.next = cur.next.next;
            }else {
                cur = cur.next;
            }
        }
        return head;
    }

    public static void main(String[] args) {
        ListNode.print(deleteDuplicates(ListNode.gen(new int[]{})));
        ListNode.print(deleteDuplicates(ListNode.gen(new int[]{1,2,3})));
        ListNode.print(deleteDuplicates(ListNode.gen(new int[]{1,1,3})));
        ListNode.print(deleteDuplicates(ListNode.gen(new int[]{1,1,1})));
        ListNode.print(deleteDuplicates(ListNode.gen(new int[]{1,1,1,2,3,3,4,5})));
    }
}
